package es.ats.codington.festival.mappers;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import es.ats.codington.festival.domain.Event;
import es.ats.codington.festival.services.PlaceDAOService;

public class EventMapper implements RowMapper<Event>{

	@Override
	public Event mapRow(ResultSet rs, int nRow) throws SQLException {
		Event event = new Event();
		PlaceDAOService placeDAO = new PlaceDAOService();
		
		event.setEventId(rs.getInt("eventid"));
		event.setEventName(rs.getString("eventname"));
		event.setEventDescription(rs.getString("eventdescription"));
		event.setDuration(rs.getString("duration"));
		event.setEventType(rs.getString("eventype"));
		event.setTickets(rs.getString("tickets"));
		event.setPlaces(placeDAO.getPlaceByIdService(rs.getInt("place_placeid")));
		
		
		return event;
	}

}
